// ticket.h

#ifndef __ticket_h__
#define __ticket_h__

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus


// Utility routines that pass a ticket to enable cooperative
// synchronous fast-forwarding of multiple threads.

// Waits until this processor is granted the ticket,
// which occurs either when the previous thread calls
// Ticket_Yield() or when any thread calls
// Ticket_EnableSharedTicket().
void Ticket_Wait();

// Gives up a ticket held by this processor, then waits
// until it is returned.  Round-robin occurs for threads
// with Sim_GetMyId() in 0..numVP-1.
void Ticket_Yield(int const numVP);

// Stops using the ticket to determine when
// Ticket_Wait() returns and enters "shared"
// mode in which any processor can run at will.
void Ticket_EnableSharedTicket();


#ifdef __cplusplus
}
#endif // __cplusplus

#endif // __ticket_h__
